package com.lww.smartbathroom.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket createApiDocket() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                // 自定义API 基本信息
                .apiInfo(this.defaultInfo())
                // 开启一个端点
                .select()
                // 开启API 生成路径
                .apis(RequestHandlerSelectors.basePackage("com.lww.smartbathroom.control"))
                // 选择生成路径
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    public ApiInfo defaultInfo() {
        return new ApiInfoBuilder()
                .title("TEST")
                .description("TEST smartbathroom")
                .version("1.0")
                .contact(new Contact("赖伟伟","","xxxxx@qq.com"))
                .build();
    }
}